package com.tools.web.wx;

import com.tools.common.object.Note;

import java.util.Objects;

/**
 * 微信用户的包装类实体
 * */
@Note("微信用户的包装类实体")
public final class WxUser {

    @Note("访问 Token")
    private final String accessToken;

    @Note("open-id")
    private final String openId;

    @Note("用户信息，以字符串形式保存着")
    private final String userData;

    WxUser(String accessToken, String openId, String userData) {
        this.accessToken = accessToken;
        this.openId = openId;
        this.userData = userData;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public String getOpenId() {
        return openId;
    }

    public String getUserData() {
        return userData;
    }

    @Override
    public String toString() {
        return "WxUser{" +
                "accessToken='" + accessToken + '\'' +
                ", openId='" + openId + '\'' +
                ", userData='" + userData + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        WxUser wxUser = (WxUser) o;
        return Objects.equals(accessToken, wxUser.accessToken) && Objects.equals(openId, wxUser.openId) && Objects.equals(userData, wxUser.userData);
    }

    @Override
    public int hashCode() {
        return Objects.hash(accessToken, openId, userData);
    }
}
